﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeneralClasses;

namespace Interface
{
    public partial class frmAllShifts : Form
    {
        Schedule schedule;
        string text = "";

        public frmAllShifts(Schedule schedule)
        {
            InitializeComponent();
            this.schedule = schedule;
        }

        public frmAllShifts(string text)
        {
            InitializeComponent();
            this.text = text;
            this.schedule = null;
        }

        void Refresh()
        {
            if (schedule != null)
            {
                int i = 0;
                int depID;

                text += "The Shifts" + Environment.NewLine + Environment.NewLine;
                text += "================================" + Environment.NewLine;
                text += "#   Date and Time   Department ID   Name" + Environment.NewLine;
                text += "================================" + Environment.NewLine;

                foreach (Shift shift in schedule.ShiftMasterList)
                {
                    foreach (Person person in shift.Persons)
                    {
                        depID = -1;

                        if (person.DepartmentTableIDs.Count > 0)
                            depID = person.DepartmentTableIDs[0];

                        text += (i + 1).ToString() + ". " + shift.StartTime + " " + depID + ": " + person.FullName + Environment.NewLine;
                        i++;
                    }
                }

                /*
                foreach(GeneralClasses.Day day in schedule.Days)
                {
                    foreach (Department department in day.Departments)
                    {
                        foreach (Shift shift in department.Shifts)
                        {
                            foreach (Person person in shift.Persons)
                            {
                                text += (i + 1).ToString() + ". " + day.DateTime + " " + department.Name + ": " + person.FullName + 
                                    Environment.NewLine;
                                i++;
                            }
                        }
                    }
                }
                 * */
            }

            tbShifts.Text = text;
        }

        private void frmAllShifts_VisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible == true)
                Refresh();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
